package com.zlp.controller;

import com.zlp.dao.SysDeptMapper;
import com.zlp.entity.SysDept;
import com.zlp.utils.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 *   部门管理
 * @author     ：ZouLiPing
 * @date       ： 2019/10/9 15:04
 */
@Api(tags = "SysDeptController", description = "部门管理")
@RestController
@RequestMapping("dept")
@Slf4j
public class SysDeptController {

    @Autowired
    private SysDeptMapper sysDeptMapper;


    @ApiOperation("获取所有部门")
    @GetMapping(value = "queryDeptList")
    @ResponseBody
    @PreAuthorize("hasAuthority('sys:dept:queryList')")
    public CommonResult<List<SysDept>> queryDeptList() {
        return CommonResult.success(sysDeptMapper.queryDeptList());
    }

    @ApiOperation("获取部门根据部门ID")
    @GetMapping(value = "queryDeptByDeptId")
    @ResponseBody
    @PreAuthorize("hasAuthority('sys:dept:queryDept')")
    public CommonResult<SysDept> queryDeptByDeptId() {
        Long deptId = 6L;
        return CommonResult.success(sysDeptMapper.selectByPrimaryKey(deptId));
    }
}
